package com.ming_za.od_updater_sdk.log;

public class BasisLogger {

    private boolean enabled = false;
    private boolean debug = false;

    public boolean isEnabled() {
        return enabled;
    }

    public void setEnabled(boolean enabled) {
        this.enabled = enabled;
    }

    public boolean isDebug() {
        return debug && enabled;
    }

    public void setDebug(boolean debug) {
        this.debug = debug;
    }

    public void info(String message) {
        sout("[INFO] " + message);
    }

    public void warn(String message) {
        sout("[WARN] " + message);
    }

    public void warn(String message, Throwable throwable) {
        sout("[WARN] " + message);
        throwable.printStackTrace();
    }

    public void error(String message) {
        sout("[ERROR] " + message);
    }

    public void error(String message, Throwable e) {
        sout("[ERROR] " + message);
        e.printStackTrace();
    }

    public void debug(String message) {
        if (debug){
            sout("[DEBUG] " + message);
        }
    }

    protected void sout(String message) {
        if (enabled){
            System.out.printf("[ODUpdater][%1$tF %1$tT] %2$s %n", System.currentTimeMillis(), message);
        }
    }
}
